package com.soft.javase.day10.practice;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/5/4
 */
public class MsgFilter {
    public static void main(String[] args) {
        String[] array = { "张三,男", "李四,女", "王二麻子,女" };

        Predicate<String> isGirl = s -> {
            String sex = s.split(",")[1];
            return sex.equals("女");
        };
        Predicate<String> isFour = s -> {
            String name = s.split(",")[0];
            return name.length() == 4;
        };

        Predicate<String> filter = isGirl.and(isFour);

        List<String> list = new ArrayList<>();
        for (String str : array) {
            if (filter.test(str)) {
                list.add(str);
            }
        }

        System.out.println(list);
    }
}
